$(function() {

	question_count.initial();
});

var question_count = {
	initial : function initial() {
		this.bindChangeSearchParam();
		this.searchPaper();
	},
	
	bindChangeSearchParam : function bindChangeSearchParam(){
		$("#question-filter dl dd input").change(function(){
            var createStart = $("#question-start-date").val().substr(0,10)+" 00:00:00";
            var createStop = $("#question-stop-date").val().substr(0,10)+" 23:59:59";
            var status = $("#questionStatus").val();
            var searchStr = $("#txt-search").val();
			if($(this).parent().parent().attr("id") == "question-filter-createTime" ){
                if(searchStr != ""){
                    document.location.href = document.getElementsByTagName('base')[0].href
                        + "admin/question/question-count/"+status+"-1?createStart="
                        +createStart+"&createStop="+createStop+"&searchStr="+searchStr;
                }else{
                    document.location.href = document.getElementsByTagName('base')[0].href
                        + "admin/question/question-count/"+status+"-1?createStart="
                        +createStart+"&createStop="+createStop;
                }
			}
			
		});

        $("#question-filter dl dd span").click(function(){
            if($(this).hasClass("label"))return false;
            var createStart = $("#question-start-date").val().substr(0,10)+" 00:00:00";
            var createStop = $("#question-stop-date").val().substr(0,10)+" 23:59:59";
            var status = $(this).data("id");
            var searchStr = $("#txt-search").val();

            if($(this).parent().parent().attr("id") == "question-filter-status" ){
                if(searchStr != ""){
                    document.location.href = document.getElementsByTagName('base')[0].href
                        + "admin/question/question-count/"+status+"-1?createStart="
                        +createStart+"&createStop="+createStop+"&searchStr="+searchStr+"&status="+status;
                }else{
                    document.location.href = document.getElementsByTagName('base')[0].href
                        + "admin/question/question-count/"+status+"-1?createStart="
                        +createStart+"&createStop="+createStop;
                }
            }
		});

        $(".pagination li a").click(function(){
            var pageId = $(this).data("id");
            if(pageId==null||pageId=="")return false;
            var createStart = $("#question-start-date").val().substr(0,10)+" 00:00:00";
            var createStop = $("#question-stop-date").val().substr(0,10)+" 23:59:59";
            var status = $("#questionStatus").val();
            var searchStr = $("#txt-search").val();

			if(searchStr != ""){
				document.location.href = document.getElementsByTagName('base')[0].href
					+ "admin/question/question-count/"+status+"-"+pageId+"?createStart="+createStart
					+"&createStop="+createStop+"&searchStr="+searchStr;
			}else{
				document.location.href = document.getElementsByTagName('base')[0].href
					+ "admin/question/question-count/"+status+"-"+pageId+"?createStart="
					+createStart+"&createStop="+createStop;
			}

        });
		
	},

	searchPaper : function searchPaper(){
		$("#btn-search").click(function(){
			var searchStr = $("#txt-search").val();
			var createStart = $("#question-start-date").val().substr(0,10)+" 00:00:00";
			var createStop = $("#question-stop-date").val().substr(0,10)+" 23:59:59";
            var status = $("#questionStatus").val();
			if(searchStr != ""){
                document.location.href = document.getElementsByTagName('base')[0].href
                    + "admin/question/question-count/"+status+"-1?createStart="
					+createStart+"&createStop="+createStop+"&searchStr="+searchStr;
			}else{
                document.location.href = document.getElementsByTagName('base')[0].href
                    + "admin/question/question-count/"+status+"-1?createStart="
                    +createStart+"&createStop="+createStop;
        	}

		});
	}
};



















